import React, { Component } from 'react';
import qs from 'qs';

console.log('qs', qs);

export default class Info extends Component {
    render() {
        console.log('this.props', this.props);
        /* this.props
          history: {length: 11, action: "PUSH", location: {…}, createHref: ƒ, push: ƒ, …}
            location:
            hash: ""
            key: "y6nliu"
            pathname: "/home/message/info"
            search: "?id=001&name=%E5%B0%8F%E5%BC%A0&age=18&say=%E6%88%91%E6%98%A
        */
        console.log('search', this.props.location.search.slice(1));//id=002&name=%E5%B0%8F%E6%9D%8E&...
        console.log('qs.parse', qs.parse(this.props.location.search.slice(1)));//{id: "001", name: "小张", age: "18", say: "我是第一"}

        const { name, age, say } = qs.parse(this.props.location.search.slice(1));
        return (
            <ul>
                <li>姓名：{name}</li>
                <li>年龄:{age}</li>
                <li>说:{say}</li>
            </ul>
        )
    }
}
